<!DOCTYPE HTML>
<html>
   <head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>知果汇</title>
		<link href="_CSS_/bootstrap.min.css" rel="stylesheet">
		<link href="_CSS_/simple-line-icons.css" rel="stylesheet">
		<link href="_CSS_/font-awesome.min.css" rel="stylesheet">
		<link href="_CSS_/jasny-bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" href="_CSS_/nanoscroller.css">
		<link href="_CSS_/pace.css" rel="stylesheet">
		<link href="_CSS_/metismenu.min.css" rel="stylesheet">
		<link href="_CSS_/style.css" rel="stylesheet">

		<!--[if lt IE 9]>
		  <script src="_JS_/html5shiv.min.js"></script>
		  <script src="_JS_/respond.min.js"></script>
		<![endif]-->
		<style type="text/css">
		    body{background-color: #ffffff;}
			.row{margin-left: 0px;margin-right: 0px;}
			.radio-box{display:inline-block;width: 64px;}
			.formControls{padding-right:50px; position: relative;}
            .del-comment{text-align: right;margin-bottom: 0;}
            .del-comment a{color:#666666;}
            .chat-list .chat-element .media-body{padding-left: 0px;}
            .chat-list .chat-element .media-body .speech-box {background-color: #ffffff;padding: 0 15px;padding-left: 0px;}
            .chat-list .chat-element .media-body .speech-box:before {border:none;}
            .chat-list .chat-element .media-body .speech-box small{margin-left: 15px;}
            .chat-list .chat-element{border-bottom: 1px solid #dcdcdc;}
		</style>
    </head>
	<body>
	<article class="page-container">
		<div class="row">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-body no-padding">
                            <div class="row">
                                <div class="col-md-8">
                                    <div class="chat-room padding-20">
                                        <ul class="chat-list list-unstyled">


                                            


                                        </ul>
                                        <div class="pager" id="page" style="text-align: right;"></div>
                                    </div>

                                </div>
                            </div>
                        </div>

                    </div>
                </div><!--col-md-6-->
            </div>	

	</article>

    <script src="_JS_/jquery.min.js"></script>
    <script src="_JS_/bootstrap.min.js"></script>
    <script src="_JS_/jasny-bootstrap.min.js"></script>
    <script src="_JS_/jquery.slimscroll.min.js"></script>
    <script src="_JS_/jquery.nanoscroller.min.js"></script>
    <script src="_JS_/metismenu.min.js"></script>
    <script src="_JS_/float-custom.js"></script>
    <script type="text/javascript" src="_JS_/layer/layer.js"></script>
    <script type="text/javascript" src="_JS_/laypage/laypage.js"></script>
    <script type="text/javascript" src="_JS_/getMyDate.js"></script>

	<script type="text/javascript">
        var url=window.location.href;
        v_id = url.split("#")[1];
        $(function(){
            newslist(1);
        });
        function newslist(page){
            $.ajax({
                type: "get",
                url: "{:url('api/video/video_comment')}",
                dataType: 'jsonp',
                jsonp:'callback',
                data:{'id':v_id,'page':page},
                success: function (msg) {
                    if(msg.code == 200){
                        //编辑器准备好之后加载内容
                        var pages=Math.ceil(msg.data.count/10);
                        $(".chat-list").html("");
                        if(msg.data.data.length>0){
                            var html="";
                            for(var i=0;i<msg.data.data.length;i++){
                                html+='<li class="clearfix chat-element">';
                                html+='<a href="javascript: void(0);" class="pull-left">';
                                html+='<img src="/static/admin/images/'+msg.data.data[i].head_img+'" alt="" class="img-circle"></a>';
                                html+='<div class="media-body "><div class="speech-box">';
                                html+='<strong>'+msg.data.data[i].username+'</strong><small>'+getMyDate((msg.data.data[i].time)*1000)+'</small>';
                                html+='<p class="margin-b-0">'+msg.data.data[i].comment+'</p>';
                                html+='<p class="del-comment"><a class="btn" onclick="comment_del(this,'+msg.data.data[i].id+')" href="#" title="删除"><i class="fa fa-trash-o"></i></a></p>';
                                html+='</div></div></li>';
                            }
                            $(".chat-list").html(html);
                            $(".chat-list").attr("pages",page);
                            //分页
                            laypage({
                                cont: 'page',
                                pages: pages,
                                curr:page,
                                jump: function(obj,first){
                                    if(!first){ //点击跳页触发函数自身，并传递当前页：obj.curr
                                        newslist(obj.curr);
                                    }
                                }
                            })
                        }else{
                            $('#page').hide();
                            $(".chat-list").html('没有评论');
                        }
                    }
                    if(msg.code==1000){
                        layer.msg('获取信息不成功!',{icon:1,time:2000});
                    }
                }
            });
        }
	  function comment_del(obj,id){
          layer.confirm('确认要删除该评论吗？',function(index){
              pages_num=$(".chat-list").attr("pages");
              $.ajax({
                  type: "get",
                  url: "/index.php/api/video/comment_del",
                  dataType: 'jsonp',
                  jsonp:'callback',
                  data: {'id':id,'status':'3'},
                  success: function (msg) {
                      if(msg.code == 200){
                          $(obj).parents("li").remove();
                          newslist(pages_num);
                          layer.msg('已删除!',{icon:1,time:1000});
                      }
                      if(msg.code==1000){
                          layer.msg('删除失败!',{icon:5,time:1000});
                      }
                  }
              });
          });
      }
	</script> 
</body>
</html>